﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:p="clr-namespace:Lithnet.Acma.Presentation"
                    xmlns:a="clr-namespace:Lithnet.Acma;assembly=Lithnet.Acma"
                    xmlns:c="clr-namespace:Lithnet.MetadirectoryServices;assembly=Lithnet.MetadirectoryServices"
                    xmlns:fim="clr-namespace:Microsoft.MetadirectoryServices;assembly=Microsoft.MetadirectoryServicesEx"
                    xmlns:core="clr-namespace:Lithnet.Common.Presentation;assembly=Lithnet.Common.Presentation">

    <DataTemplate  DataType="{x:Type p:AttributePresenceRuleViewModel}">
        <StackPanel>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Label Content="Value source"
                       Grid.Row="0"
                       Grid.Column="0"
                       Margin="2" />
                <RadioButton Content="An attribute on this object"
                             IsChecked="{Binding Path=IsLocal}"
                             Grid.Row="0"
                             Grid.Column="1"
                             Margin="2" />

                <RadioButton Content="An attribute on a referenced object"
                             IsChecked="{Binding Path=IsReferenced}"
                             Grid.Row="1"
                             Grid.Column="1"
                             Margin="2" />

                <ComboBox ItemsSource="{Binding Path=AllowedReferenceSourceAttributes}"
                          SelectedItem="{Binding Path=ReferencedObjectAttribute, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          DisplayMemberPath="Name"
                          Grid.Row="2"
                          Grid.Column="1"
                          IsEnabled="{Binding Path=IsReferenced, Mode=OneWay}"
                          Margin="2"
                          IsEditable="True" />
                
                <Label Content="Attribute"
                       Grid.Row="3"
                       Grid.Column="0"
                       Margin="2" />
                <ComboBox ItemsSource="{Binding Path=AllowedAttributes}"
                          SelectedItem="{Binding Path=Attribute, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          DisplayMemberPath="Name"
                          Grid.Row="3"
                          Grid.Column="1"
                          Margin="2" 
                          IsEditable="True"/>

                <Label Content="Presence state"
                       Grid.Row="4"
                       Grid.Column="0"
                       Margin="2" />
                <ComboBox ItemsSource="{Binding Source={core:EnumExtension {x:Type c:PresenceOperator}}}"
                          SelectedValue="{Binding Path=Operator, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          SelectedValuePath="Value"
                          Grid.Row="4"
                          Grid.Column="1"
                          Margin="2" />

                <Label Content="View"
                       Grid.Row="5"
                       Grid.Column="0"
                       Margin="2"
                       Visibility="{Binding Path=CanSetView, Converter={StaticResource BooleanToVisibilityConverter}}" />

                <ComboBox ItemsSource="{Binding Source={core:EnumExtension {x:Type a:HologramView}}}"
                          SelectedValue="{Binding Path=View, ValidatesOnDataErrors=True, ValidatesOnExceptions=true}"
                          SelectedValuePath="Value"
                          Grid.Row="5"
                          Grid.Column="1"
                          IsEnabled="{Binding Path=CanSetView, Mode=OneWay}"
                          Margin="2"
                          Visibility="{Binding Path=CanSetView, Converter={StaticResource BooleanToVisibilityConverter}}" />
            </Grid>
        </StackPanel>
    </DataTemplate>
</ResourceDictionary>